/**
 * Using base_exp.txt, a 22K text file containing one thousand lines 
 * with a base/exponent pair on each line, determine which line number 
 * has the greatest numerical value.
 */

#include <iostream>
#include <fstream>
#include <cmath>
#include "euler.h"

BEGIN_PROBLEM(99, solve_problem_99)
	PROBLEM_TITLE("Find the greatest base/exponent pair")
	PROBLEM_ANSWER("709")
	PROBLEM_DIFFICULTY(1)
	PROBLEM_FUN_LEVEL(1)
	PROBLEM_TIME_COMPLEXITY("n")
	PROBLEM_SPACE_COMPLEXITY("1")
END_PROBLEM()

static void solve_problem_99()
{
	std::ifstream fs("input/base_exp.txt");
	int best_line = 0;
	double best_value = 0;
	int base, exp;
	char c;
	for (int line = 1; fs >> base >> c >> exp; ++line) // 519432,525806
	{
		double value = std::log((double)base) * (double)exp;
		if (value > best_value)
		{
			best_value = value;
			best_line = line;
		}
	}
	std::cout << best_line << std::endl;
}
